<template>
  <div class="pay">
    <div class="top">
      <van-nav-bar
        title="订单填写"
        left-text="返回"
        left-arrow
        fixed
        @click-left="onClickLeft"
      />
    </div>
    <div class="header">
      <p>
        {{this.nwney.title}}
      </p>
      <h3>出发时间：{{tiems}}</h3>
      <h3>行程套餐：{{this.nwney.package}}</h3>
    </div>
    <main>
      <div class="item">
        <span>联系人</span
        ><input type="text" placeholder="请输入联系人" v-model="name" />
      </div>
      <div class="item">
        <span>手机号码</span
        ><input type="text" placeholder="请输入手机号码" v-model="phone" />
      </div>
    </main>
    <div class="person">
      <div class="itemz">
        <div class="left">
          <span>成人<i>￥{{this.nwney.num}}/人</i></span>
        </div>
        <div class="right">
          <van-stepper v-model="value" />
        </div>
      </div>
      <div class="itemz">
        <div class="left">
          <span>儿童<i>￥{{this.nwney.chilidrennum}}/人</i></span>
        </div>
        <div class="right">
          <van-stepper v-model="value1" min="0" />
        </div>
      </div>
      <div class="itemz">
        <div class="left">
          <span>婴儿<i>￥{{this.nwney.babyprice}}/人</i></span>
        </div>
        <div class="right">
          <van-stepper v-model="value2" min="0" />
        </div>
      </div>
    </div>

    <div class="bottom">
      <div class="itme">
        <p>发票信息</p>
        <b>支付成功后,可通过会员中心-选择订单-查看详情-补开发票申请发票</b>
      </div>
      <div class="itme">
        <p>发票信息</p>
        <input type="text" placeholder="请输入内容" />
      </div>
      <div class="itme">
        <p>推荐码</p>
        <input type="text" placeholder="选填" />
      </div>
    </div>

    <footer>
      <div class="left1" @click="flag = !flag">
        <div v-show="!flag" class="ball"></div>
        <div v-show="flag" class="ball1"></div>
      </div>
      <div class="right1">
        <span
          >本人及本人代表报名的全体客人，对以上报名所填资料及勾选内容确认无误，并已详细阅读<i>注意事项</i>,了解并同意相关条款的约定，现予以以确认</span
        >
      </div>
    </footer>

    <div class="money">
      <div class="left2">
        <p>应付款：</p>
        <span><i>￥</i>{{total}}</span>
      </div>
      <div class="right2">
        <span @click="no" v-show="!flag">提交订单</span>
        <span class="p1" @click="go" v-show="flag">提交订单</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      name: "",
      phone: "",
      value: 1,
      value1: 0,
      value2: 0,
      flag: false,
      mwney:null,
      totalall:null,
      num:'',
      num1:'',
      num2:'',
      main:[],
      tiems:'',
    };
  },
  methods: {
    no() {
      this.$toast("还有信息未填完，请填好信息。");
    },
    go() {
      this.$toast("提交成功");
      this.nwney.total = this.total;//总价
      this.nwney.pnum = this.value;//成人人数
      this.nwney.childrennum = this.value1;//儿童人数
      this.nwney.babynum = this.value2;//婴儿人数
      this.nwney.tiems = this.tiems;
      console.log(this.nwney.tiems);
      this.main.push(this.nwney);
      window.localStorage.setItem("pay",JSON.stringify(this.main));
      this.$router.push("/home");
    },
    onClickLeft() {
      this.$router.go(-1);
    },
  },
  computed:{
    //总价
    total(){
        return (this.num * this.value) + (this.num1 * this.value1) + (this.num2 * this.value2);
    }
  },
  created(){
    console.log(this.$route.query);
    setTimeout(()=>{
      this.tiems = this.$route.query.tiems;
    },10)
    console.log(this.tiems);
    // console.log(this.$route.params.lists);
    this.nwney = this.$route.query.lists;
    // console.log(this.nwney);
    this.num = this.nwney.num;
    this.num1 = this.nwney.chilidrennum;
    this.num2 = this.nwney.babyprice;
    // console.log(this.$route.params.tiems);
    this.tiems = this.$route.params.tiems;
    // console.log(window.localStorage.pay);
    if(window.localStorage.getItem("pay")){
      this.main = JSON.parse(window.localStorage.getItem("pay"))
    }else{
      this.main;
    }
  }
};
</script>

<style lang="scss" scoped>
.pay {
    .top{
        ::v-deep .van-nav-bar .van-icon{
            color: #000;
        }
        ::v-deep .van-nav-bar__text{
            color: #000;
        }
    }
  .header {
    margin-top: 46px;
    padding: 10px;
    border-bottom: 10px solid #f5f5f5;
    p {
      font-size: 14px;
      color: #333;
    }
    h3 {
      font-size: 16px;
      padding: 4px 0;
    }
  }
  main {
    border-bottom: 10px solid #f5f5f5;
    .item {
      display: flex;
      margin: auto 16px;
      padding: 12px 0px;
      border-bottom: 1px solid #ccc;
      &:last-of-type {
        border: none;
      }
      span {
        font-size: 14px;
        font-weight: bold;
      }
      input {
        font-size: 14px;
        margin-left: 10px;
        flex: 1;
        border: none;
        outline: none;
      }
    }
  }
  .person {
    padding: 12px 16px;
    border-bottom: 10px solid #f5f5f5;
    .itemz {
      display: flex;
      justify-content: space-between;
      padding: 6px 0;
      .left {
        font-size: 14px;
        span {
          color: #333;
          i {
            margin-left: 16px;
            font-style: normal;
            color: #ff5555;
          }
        }
      }
    }
  }
  .bottom {
    border-bottom: 10px solid #f5f5f5;
    .itme {
      display: flex;
      margin: auto 16px;
      padding: 12px 0;
      border-bottom: 1px solid #ccc;
      align-items: center;
      &:last-of-type {
        border: none;
      }
      &:last-of-type input {
        margin-left: 34px;
      }
      &:first-child p {
        width: 100px;
      }

      p {
        font-size: 14px;
        font-weight: bold;
      }
      b {
        font-weight: normal;
        font-size: 12px;
        color: #ccc;
      }
      input {
        font-size: 14px;
        margin-left: 20px;
        flex: 1;
        border: none;
        outline: none;
      }
    }
  }
  footer {
    padding: 12px 16px 60px 16px;
    display: flex;
    align-items: center;
    background: #f5f5f5;
    .left1 {
      width: 30%;
      .ball {
        border: 1px solid #999;
        border-radius: 50%;
        width: 20px;
        height: 20px;
      }
      .ball1 {
        border: 1px solid #999;
        border-radius: 50%;
        width: 20px;
        height: 20px;
        background: #fbc659;
      }
    }
    .right1 {
      span {
        font-size: 12px;
        i {
          margin: 0 5px;
          font-style: normal;
          color: #fbc659;
          text-decoration: underline;
        }
      }
    }
  }
  .money {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    height: 52px;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #fff;
    box-sizing: border-box;
    .left2 {
      display: flex;
      align-items: center;
      p {
        font-size: 14px;
      }
      span {
        color: #ff5555;
        font-size: 24px;
        i {
          font-size: 14px;
          font-style: normal;
        }
      }
    }
    .right2 {
      span {
        background: #fff699;
        color: #b4b4b4;
        padding: 10px 20px;
        border-radius: 25px;
      }
      .p1 {
        background: #ffe600;
        color: #333;
        padding: 10px 20px;
        border-radius: 25px;
      }
    }
  }
}
</style>
